const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()
  let format1 = `${year}-${month}-${day}`
  let format2 = [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':')
  let format3 = [year, month, day, hour, minute, second].map(formatNumber).join("")
  return {
    format1,
    format2,
    format3
  }
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}

let showModal = msg => {
  wx.showModal({
    title: '提示',
    content: msg,
    showCancel: false,
    confirmColor: "#1296db",
    success (res) {
      if (res.confirm) {
       
      } else if (res.cancel) {
        
      }
    }
  })
}

module.exports = {
  formatTime,
  showModal
}
